import globals from "globals";
import pluginJs from "@eslint/js";
import tseslint from "typescript-eslint";
import pluginReact from "eslint-plugin-react";

/** @type {import('eslint').Linter.Config[]} */
export default [
  { files: ["**/*.{js,mjs,cjs,ts,jsx,tsx}"] },
  {
    extends: [
      "react-app",
      "react-app/jest",
      "plugin:@typescript-eslint/recommended",
      "prettier",
    ],
    plugins: ["@typescript-eslint", "react-hooks"],
    rules: {
      "react-hooks/rules-of-hooks": "error",
      "react-hooks/exhaustive-deps": "warn",
    },
    languageOptions: {
      ecmaFeatures: {
        jsx: true,
        tsx: true, // 启用 TypeScript JSX 支持
      },
      ecmaVersion: 2020, // 或者你项目中使用的 ECMAScript 版本
    },
  },
  pluginJs.configs.recommended,
  ...tseslint.configs.recommended,
  pluginReact.configs.flat.recommended,
];
